/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wisnu.scs.add;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *
 * @author Wisnu Wardoyo
 */
public class DateFactory {

    public static List<Date> list;

    public static List<Date> getMonthOfDay(Date date) {
        list = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        calendar.add(Calendar.MONTH, 1);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.add(Calendar.DATE, -1);

        Date lastDayOfMonth = calendar.getTime();

        calendar.add(Calendar.MONTH, 0);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.add(Calendar.DATE, 0);

        Date firstDayOfMonth = calendar.getTime();
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        list.add(firstDayOfMonth);
        list.add(lastDayOfMonth);

        return list;

//      System.out.println("Today            : " + sdf.format(firstDayOfMonth));
//      System.out.println("Last Day of Month: " + sdf.format(lastDayOfMonth));
    }

}
